import request from '../utils/request';

const http = {
    doLogin:(param) => {
        return request({
            url: './token',
            method: 'post',
            data: param
        });
    },
    fetchData:(query) => {
        return request({
            url: './v1/table.json',
            method: 'get',
            params: query
        });
    },
    getOrders:(query) => {
        return request({
            url: './v1/orders',
            method: 'get',
            params: query
        });
    },
    getUsers:(query) => {
        return request({
            url: './v1/users',
            method: 'get',
            params: query
        });
    },
    orderDetail:(id) => {
        return request({
            url: './v1/order_detail/' + id,
            method: 'get',
        });
    },
    editOrderDetail:(id, data) => {
        return request({
            url: './v1/order_detail/' + id,
            method: 'put',
            data: data,
        });
    },
    deliver:(id) => {
        return request({
            url: './v1/deliver/' + id,
            method: 'put',
        });
    },
    completeOrder:(data) => {
        return request({
            url: './v1/confirm_order',
            method: 'post',
            data: data,
        });
    },
    getSkuList:(query) => {
        return request({
            url: './v1/skus',
            method: 'get',
            params: query
        });
    },
    getCats:() => {
        return request({
            url: './v1/cats?type=1',
            method: 'get'
        });
    },
    stockLog:(skuId) => {
        return request({
            url: './v1/stock_log/' + skuId,
            method: 'get'
        });
    },
    getSku:(id) => {
        return request({
            url: './v1/sku/' + id,
            method: 'get'
        });
    },
    getBrands:() => {
        return request({
            url: './v1/brands',
            method: 'get'
        });
    },
    editPassword:(data) => {
        return request({
            url: './v1/edit_password',
            method: 'put',
            data: data,
        });
    },
    qiniuToken:() => {
        return request({
            url: './v1/qiniu_token',
            method: 'get'
        });
    },
    editSku:(id, data) => {
        return request({
            url: './v1/sku/' + id,
            method: 'put',
            data: data
        });
    },
    editCat:(id, data) => {
        return request({
            url: './v1/cat/' + id,
            method: 'put',
            data: data
        });
    },
    editSpu:(id, data) => {
        return request({
            url: './v1/spu/' + id,
            method: 'put',
            data: data
        });
    },
    editGroup:(data) => {
        return request({
            url: './v1/group',
            method: 'post',
            data: data
        });
    },
    getConf:(key) => {
        return request({
            url: './v1/conf/' + key,
            method: 'get',
        });
    },
    editConf:(conf) => {
        return request({
            url: './v1/conf_setting',
            method: 'post',
            data: conf
        });
    },
    editSpuState:(id, data) => {
        return request({
            url: './v1/spu_state/' + id,
            method: 'put',
            data: data
        });
    },
    editSpuType:(id, data) => {
        return request({
            url: './v1/spu_type/' + id,
            method: 'put',
            data: data
        });
    },
    delSpu:(id) => {
        return request({
            url: './v1/spu_del/' + id,
            method: 'put'
        });
    },
    delSku:(id) => {
        return request({
            url: './v1/sku_del/' + id,
            method: 'put'
        });
    },
    editUser:(id, data) => {
        return request({
            url: './v1/user/' + id,
            method: 'put',
            data: data
        });
    },
    editMoney:(id, data) => {
        return request({
            url: './v1/user_money/' + id,
            method: 'put',
            data: data
        });
    },
    reqCatAttr:(cat_id) => {
        return request({
            url: './v1/cat_attr/' + cat_id,
            method: 'get',
        });
    },
    reqSkuAttr:(skuId) => {
        return request({
            url: './v1/sku_attr/' + skuId,
            method: 'get',
        });
    },
    curUser:() => {
        return request({
            url: './v1/cur_user/',
            method: 'get',
        });
    },
    editSkuAttr:(skuId, data) => {
        return request({
            url: './v1/sku_attr/' + skuId,
            method: 'put',
            data: data,
        });
    },
    addOrder:(data) => {
        return request({
            url: './v1/order',
            method: 'post',
            data: data,
        });
    },
    addUser:(data) => {
        return request({
            url: './v1/user',
            method: 'post',
            data: data,
        });
    },
    addStock:(data) => {
        return request({
            url: './v1/stock',
            method: 'post',
            data: data,
        });
    },
    getSpus:(query) => {
        return request({
            url: './v1/spus',
            method: 'get',
            params: query,
        });
    },
    getGroupProduct:(query) => {
        return request({
            url: './v1/group/product',
            method: 'get',
            params: query,
        });
    },
    getSpuSample:() => {
        return request({
            url: './v1/spu_sample',
            method: 'get',
        });
    },
    addSku:(data) => {
        return request({
            url: './v1/sku',
            method: 'post',
            data: data,
        });
    },
    saveSpuImg:(id, data) => {
        return request({
            url: './v1/spu_detail/' + id,
            method: 'post',
            data: data,
        });
    },
    getSpuDetail:(id) => {
        return request({
            url: './v1/spu/' + id,
            method: 'get',
        });
    },
    getSpuSkus:(id) => {
        return request({
            url: './v1/spu_skus/' + id,
            method: 'get',
        });
    },
    getSales:() => {
        return request({
            url: './v1/sales',
            method: 'get',
        });
    },
    getSkuSales:(query) => {
        return request({
            url: './v1/sku_sales',
            method: 'get',
            params: query
        });
    },
    getConfs:() => {
        return request({
            url: './v1/all_conf',
            method: 'put'
        });
    },
    getStockSales:(day) => {
        return request({
            url: './v1/stock_lack?day=' + day ,
            method: 'get',
        });
    },
    getSalesTrend:() => {
        return request({
            url: './v1/sales_trend',
            method: 'get',
        });
    },
    getProfitTrend:() => {
        return request({
            url: './v1/profit_trend?day=7',
            method: 'get',
        });
    },
    getPubConf: () => {
        return  request({
            url: './v1/pub_conf',
            method: 'get',
        });
    },
    getAgent:(query) => {
        return request({
            url: './v1/agent_list',
            method: 'get',
            params: query,
        });
    },
    saveAgent:(data) => {
        return request({
            url: './v1/agent',
            method: 'post',
            data: data,
        });
    },
};
export {http}
